package com.fp.m7.client.event;

import com.google.gwt.event.shared.GwtEvent;

/**
 * An event which will be displayed in InfoPresenter for the specified time.
 * 
 * @author 7
 */
public class InfoEvent extends GwtEvent<InfoEventHandler> {

    public static final Type<InfoEventHandler> TYPE = new Type<InfoEventHandler>();

    private String message;

    private UserMessageType type = UserMessageType.INFO;
    private int delayMs = 10 * 1000; // [ms

    public InfoEvent() {
    }

    public InfoEvent(String message) {
        this();
        this.message = message;
    }

    public InfoEvent(String message, UserMessageType type) {
        this(message);
        this.type = type;
    }

    @Override
    protected void dispatch(InfoEventHandler handler) {
        handler.onBackgroundEvent(this);
    }

    @Override
    public Type<InfoEventHandler> getAssociatedType() {
        return TYPE;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public UserMessageType getType() {
        return type;
    }

    public void setType(UserMessageType type) {
        this.type = type;
    }

    public int getDelayMs() {
        return delayMs;
    }

    public void setDelayMs(int delayMs) {
        this.delayMs = delayMs;
    }

    public static enum UserMessageType {
        INFO, WARNING, SUCCESS
    }

}